# from a fasta file with only "> name" for descriptor lines,
# format for input to TCW as an annoDB

use strict;

	## Change 
	my $type="nt";
	my $species="diaci";
	my $descript= "sequence";
	my $infile = " diaci1.1_transcripts.fasta";
	my $outfile = "diaci1.1.fa";

	print "Descriptor lines will be:\n";
	print ">" . $type . "|<name> " . $descript . " OS=" . $species . "\n";
	print "Write ", $outfile, " \n";
	open IN, "<$infile" or die "cannot open $infile\n";
	open OUT, ">$outfile" or die "cannot open $outfile\n";
	
	my $prt=0; my $cnt=0; my $sum=0; my $line;
	
	while ($line = <IN>) {
		if ($line =~ />(.*)$/) {
			my $t = $1;
			print OUT ">" . $type . "|" . $t . " " . $descript . " OS=" . $species . "\n";
			$cnt++;
		}
		else
		{
			print OUT $line;
			$sum += length($line);
		}
	}

	my $avg = 0;
	if ($cnt!=0) {$avg = $sum/$cnt;}
	printf("Wrote %d average length %6.2f\n", $cnt, $avg);			


